﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Drawing;

namespace WF_Loadout_Editor
{
    public class WarframeMod : BaseMod
    {
        public enum Stat
        {
            Health = 0,
            Energy,         // 1
            Armor,          // 2
            Shield,         // 3
            ShieldRecharge, // 4
            Stamina,        // 5
            StaminaRecharge,// 6
            SprintSpeed,    // 7
            Other           // 8
        }                   
                            
        private Stat statType;
        public Stat StatType
        {
            get { return statType; }
            set { statType = value; }
        }

        public WarframeMod()
        {

        }

        public WarframeMod(string name1, string description1, ModType type1, Polarity polarityType1, float statModifier1, float currentStat1, int currentRank1, int maxRank1, int baseCost1, int statType1)
            : base(name1, description1, type1, polarityType1, statModifier1, currentStat1, currentRank1, maxRank1, baseCost1)
        {
            statType = (Stat)statType1;

            string fileName = "Resources/Warframe Mods/";
            string fileExt = ".png";
            fileName += name1;
            fileName = fileName + fileExt;
            if (Name != "Default")
                Picture = Image.FromFile(fileName);
        }

        public override Object ModifyStat(Object obj)
        {
            // modifies a warframe stat based on the mod
            Warframe warframe = (Warframe) obj;
            switch (statType)
            {
                case Stat.Health:
                    float newHealth = warframe.BaseHealth * (this.CurrentStat / 100.0f);
                    warframe.Health += newHealth;
                    break;
                case Stat.Energy:
                    float newEnergy = warframe.BaseEnergy * (this.CurrentStat / 100.0f);
                    warframe.Energy += newEnergy;
                    break;
                case Stat.Armor:
                    float newArmor = warframe.BaseArmor * (this.CurrentStat / 100.0f);
                    warframe.Armor += newArmor;
                    break;
                case Stat.Shield:
                    float newShield = warframe.BaseShield * (this.CurrentStat / 100.0f);
                    warframe.Shield += newShield;
                    break;
                case Stat.Stamina:
                    float newStamina = warframe.Stamina * (this.CurrentStat / 100.0f);
                    warframe.Stamina += newStamina;
                    break;
                case Stat.ShieldRecharge:
                    float newShieldRecharge = warframe.ShieldRecharge * (this.CurrentStat / 100.0f);
                    warframe.ShieldRecharge += newShieldRecharge;
                    break;
                case Stat.StaminaRecharge:
                    float newStaminaRecharge = warframe.StaminaRecharge * (this.CurrentStat / 100.0f);
                    warframe.StaminaRecharge += newStaminaRecharge;
                    break;
                case Stat.SprintSpeed:
                    float newSprintSpeed = warframe.SprintSpeed * (this.CurrentStat / 100.0f);
                    warframe.SprintSpeed += newSprintSpeed;
                    break;
                default:
                    break;
            }
            return obj;
        }
    }
}
